<template>
  <div class="m-index">
    <!-- 头部导航 -->
    <w-header :return-index="returnIndex" @on-changeNav="onChangeMenu"></w-header>
    <!-- 主体内容 -->
    <div class="app-container clearfix">
      <div class="menu fl">
        <w-side-menu :menus="menuList" :title="title"></w-side-menu>
      </div>
      <div class="view-right">
        <w-bread-crumbs></w-bread-crumbs>       
          <router-view></router-view>                      
      </div>
    </div>
  </div>
</template>

<script>
import OrderItem from '../pages/orderMange/components/orderItem'
import { session } from 'js/util'

export default {
  data() {
    return {
      title: '控制台',
      menuList: [
        {
          twoMenuName: '欢迎页',
          isShow: true
        }
      ],
      returnIndex: 0
    }
  },
  components: {
    'orderItem': OrderItem
  },
  created() {
    this.returnIndex = this.$route.query.cIndex || 0
    // 使页面刷新不改变其当前的菜单列
    if (session.get('curMenu')) {
      this.menuList = session.get('curMenu')
    }
    if (session.get('curMenuTitle')) {
      this.title = session.get('curMenuTitle')
    }
  },
  methods: {
    /**
     * 点击以及菜单获取所属的下级菜单数据
     */
    onChangeMenu(title) {
      this.title = title // 选择的一级菜单
      if (session.get('curMenu')) {
        this.menuList = session.get('curMenu')
      }
      if (session.get('curMenuTitle')) {
        this.title = session.get('curMenuTitle')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.menu, .view-right {
  display: inline-block;
}
.menu {
  margin-right: 18px;
}
.view-right {
  width: 1190px;
}
</style>
